package com.wasion.gydpe.ice;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class CommDataOwnerInitializer {

	private static Map owners = new HashMap();

	public static CommDataOwner getOwner(Object user) {
		return (CommDataOwner) owners.get(user);
	}

	public static void addFrame(Object user, int seqId) {
		synchronized (user) {
			if (owners.containsKey(user)) {
				CommDataOwner owner = (CommDataOwner) owners.get(user);
				List seqIds = owner.getSeqIds();
				if (!seqIds.contains(seqId)) {
					seqIds.add(seqId);
				}

			} else {
				CommDataOwner owner = new CommDataOwner();
				List seqIds = new ArrayList();
				seqIds.add(seqId);
				owner.setSeqIds(seqIds);
				owners.put(user, owner);
			}
			user.notifyAll();
		}
	}

	public static void doClear() {
		owners.clear();
	}

}
